/**
 */
package proyecto.testcasetool.impl;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import proyecto.testcasetool.ActionStep;
import proyecto.testcasetool.Agent;
import proyecto.testcasetool.Parameter;
import proyecto.testcasetool.TestcasetoolPackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Action Step</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link proyecto.testcasetool.impl.ActionStepImpl#getPrestate <em>Prestate</em>}</li>
 *   <li>{@link proyecto.testcasetool.impl.ActionStepImpl#getPoststate <em>Poststate</em>}</li>
 *   <li>{@link proyecto.testcasetool.impl.ActionStepImpl#getParameter <em>Parameter</em>}</li>
 *   <li>{@link proyecto.testcasetool.impl.ActionStepImpl#getAgent <em>Agent</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ActionStepImpl extends StepImpl implements ActionStep {
	/**
	 * The default value of the '{@link #getPrestate() <em>Prestate</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPrestate()
	 * @generated
	 * @ordered
	 */
	protected static final String PRESTATE_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getPrestate() <em>Prestate</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPrestate()
	 * @generated
	 * @ordered
	 */
	protected String prestate = PRESTATE_EDEFAULT;

	/**
	 * The default value of the '{@link #getPoststate() <em>Poststate</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPoststate()
	 * @generated
	 * @ordered
	 */
	protected static final String POSTSTATE_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getPoststate() <em>Poststate</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPoststate()
	 * @generated
	 * @ordered
	 */
	protected String poststate = POSTSTATE_EDEFAULT;

	/**
	 * The cached value of the '{@link #getParameter() <em>Parameter</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getParameter()
	 * @generated
	 * @ordered
	 */
	protected Parameter parameter;

	/**
	 * The cached value of the '{@link #getAgent() <em>Agent</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getAgent()
	 * @generated
	 * @ordered
	 */
	protected Agent agent;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ActionStepImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return TestcasetoolPackage.Literals.ACTION_STEP;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getPrestate() {
		return prestate;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setPrestate(String newPrestate) {
		String oldPrestate = prestate;
		prestate = newPrestate;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, TestcasetoolPackage.ACTION_STEP__PRESTATE, oldPrestate, prestate));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getPoststate() {
		return poststate;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setPoststate(String newPoststate) {
		String oldPoststate = poststate;
		poststate = newPoststate;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, TestcasetoolPackage.ACTION_STEP__POSTSTATE, oldPoststate, poststate));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Parameter getParameter() {
		return parameter;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetParameter(Parameter newParameter, NotificationChain msgs) {
		Parameter oldParameter = parameter;
		parameter = newParameter;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, TestcasetoolPackage.ACTION_STEP__PARAMETER, oldParameter, newParameter);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setParameter(Parameter newParameter) {
		if (newParameter != parameter) {
			NotificationChain msgs = null;
			if (parameter != null)
				msgs = ((InternalEObject)parameter).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - TestcasetoolPackage.ACTION_STEP__PARAMETER, null, msgs);
			if (newParameter != null)
				msgs = ((InternalEObject)newParameter).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - TestcasetoolPackage.ACTION_STEP__PARAMETER, null, msgs);
			msgs = basicSetParameter(newParameter, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, TestcasetoolPackage.ACTION_STEP__PARAMETER, newParameter, newParameter));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Agent getAgent() {
		if (agent != null && agent.eIsProxy()) {
			InternalEObject oldAgent = (InternalEObject)agent;
			agent = (Agent)eResolveProxy(oldAgent);
			if (agent != oldAgent) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, TestcasetoolPackage.ACTION_STEP__AGENT, oldAgent, agent));
			}
		}
		return agent;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Agent basicGetAgent() {
		return agent;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetAgent(Agent newAgent, NotificationChain msgs) {
		Agent oldAgent = agent;
		agent = newAgent;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, TestcasetoolPackage.ACTION_STEP__AGENT, oldAgent, newAgent);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setAgent(Agent newAgent) {
		if (newAgent != agent) {
			NotificationChain msgs = null;
			if (agent != null)
				msgs = ((InternalEObject)agent).eInverseRemove(this, TestcasetoolPackage.AGENT__AGENT_ACTION_STEP, Agent.class, msgs);
			if (newAgent != null)
				msgs = ((InternalEObject)newAgent).eInverseAdd(this, TestcasetoolPackage.AGENT__AGENT_ACTION_STEP, Agent.class, msgs);
			msgs = basicSetAgent(newAgent, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, TestcasetoolPackage.ACTION_STEP__AGENT, newAgent, newAgent));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case TestcasetoolPackage.ACTION_STEP__AGENT:
				if (agent != null)
					msgs = ((InternalEObject)agent).eInverseRemove(this, TestcasetoolPackage.AGENT__AGENT_ACTION_STEP, Agent.class, msgs);
				return basicSetAgent((Agent)otherEnd, msgs);
		}
		return super.eInverseAdd(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case TestcasetoolPackage.ACTION_STEP__PARAMETER:
				return basicSetParameter(null, msgs);
			case TestcasetoolPackage.ACTION_STEP__AGENT:
				return basicSetAgent(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case TestcasetoolPackage.ACTION_STEP__PRESTATE:
				return getPrestate();
			case TestcasetoolPackage.ACTION_STEP__POSTSTATE:
				return getPoststate();
			case TestcasetoolPackage.ACTION_STEP__PARAMETER:
				return getParameter();
			case TestcasetoolPackage.ACTION_STEP__AGENT:
				if (resolve) return getAgent();
				return basicGetAgent();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case TestcasetoolPackage.ACTION_STEP__PRESTATE:
				setPrestate((String)newValue);
				return;
			case TestcasetoolPackage.ACTION_STEP__POSTSTATE:
				setPoststate((String)newValue);
				return;
			case TestcasetoolPackage.ACTION_STEP__PARAMETER:
				setParameter((Parameter)newValue);
				return;
			case TestcasetoolPackage.ACTION_STEP__AGENT:
				setAgent((Agent)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case TestcasetoolPackage.ACTION_STEP__PRESTATE:
				setPrestate(PRESTATE_EDEFAULT);
				return;
			case TestcasetoolPackage.ACTION_STEP__POSTSTATE:
				setPoststate(POSTSTATE_EDEFAULT);
				return;
			case TestcasetoolPackage.ACTION_STEP__PARAMETER:
				setParameter((Parameter)null);
				return;
			case TestcasetoolPackage.ACTION_STEP__AGENT:
				setAgent((Agent)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case TestcasetoolPackage.ACTION_STEP__PRESTATE:
				return PRESTATE_EDEFAULT == null ? prestate != null : !PRESTATE_EDEFAULT.equals(prestate);
			case TestcasetoolPackage.ACTION_STEP__POSTSTATE:
				return POSTSTATE_EDEFAULT == null ? poststate != null : !POSTSTATE_EDEFAULT.equals(poststate);
			case TestcasetoolPackage.ACTION_STEP__PARAMETER:
				return parameter != null;
			case TestcasetoolPackage.ACTION_STEP__AGENT:
				return agent != null;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (prestate: ");
		result.append(prestate);
		result.append(", poststate: ");
		result.append(poststate);
		result.append(')');
		return result.toString();
	}

} //ActionStepImpl
